<?php

/**
 * Campanha form base class.
 *
 * @method Campanha getObject() Returns the current form's model object
 *
 * @package    siscampanha
 * @subpackage form
 * @author     Alexandre Haguiar
 */
abstract class BaseCampanhaForm extends BaseFormPropel
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'            => new sfWidgetFormInputHidden(),
      'ano'           => new sfWidgetFormInputText(),
      'data_eleicoes' => new sfWidgetFormDateTime(),
      'cargo_id'      => new sfWidgetFormPropelChoice(array('model' => 'Cargo', 'add_empty' => false)),
      'candidato_id'  => new sfWidgetFormPropelChoice(array('model' => 'Candidato', 'add_empty' => false)),
    ));

    $this->setValidators(array(
      'id'            => new sfValidatorChoice(array('choices' => array($this->getObject()->getId()), 'empty_value' => $this->getObject()->getId(), 'required' => false)),
      'ano'           => new sfValidatorInteger(array('min' => -2147483648, 'max' => 2147483647)),
      'data_eleicoes' => new sfValidatorDateTime(),
      'cargo_id'      => new sfValidatorPropelChoice(array('model' => 'Cargo', 'column' => 'id')),
      'candidato_id'  => new sfValidatorPropelChoice(array('model' => 'Candidato', 'column' => 'id')),
    ));

    $this->widgetSchema->setNameFormat('campanha[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    parent::setup();
  }

  public function getModelName()
  {
    return 'Campanha';
  }


}
